package com.lc.tgxm.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lc.tgxm.R;
import com.lc.tgxm.model.BannerMod;
import com.lc.tgxm.util.ImageUtils;
import com.zcx.helper.pager.CarouselChild;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

/**
 * HomeBannerView
 * Created by Lei on 2016/7/27.
 */
public class HomeBannerView extends CarouselChild<BannerMod> {

    public HomeBannerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected boolean isPlay() {
        return true;
    }

    @Override
    protected View getView(BannerMod bm) {

        ImageView imageView = new ImageView(getContext());

        imageView.setScaleType(ImageView.ScaleType.FIT_XY);

        ImageUtils.glideLoader(bm.imgurl, imageView);

        return imageView;
    }

    @Override
    protected View indicatorLayout(LinearLayout indicatorLayout) {

        int size = ScaleScreenHelperFactory.getInstance().getWidthHeight(12);

        indicatorLayout.setGravity(Gravity.BOTTOM | Gravity.RIGHT);

        indicatorLayout.setPadding(0, size, 0, size);

        return indicatorLayout;
    }

    @Override
    protected View indicator(View indicator) {

        int size = ScaleScreenHelperFactory.getInstance().getWidthHeight(10);
        int size2 = ScaleScreenHelperFactory.getInstance().getWidthHeight(10);
        int size3 = ScaleScreenHelperFactory.getInstance().getWidthHeight(5);

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(size, size2);

        layoutParams.leftMargin = layoutParams.rightMargin = size3;

        indicator.setLayoutParams(layoutParams);

        return indicator;
    }

    @Override
    protected int indicatorOn() {
        return R.drawable.shape_ring_blue;
    }

    @Override
    protected int indicatorOff() {
        return R.drawable.shape_ring_white;
    }
}
